home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / php.exe / Character Functions.php < prev    next >
Encoding:
PHP Script  |  2001-07-03  |  2.8 KB  |  53 lines

  1. //**************************************
  2.     //     
  3.     // Name: Character Functions
  4.     // Description:Functions like isalpha(),
  5.     //     isdigit(), etc.These functions expect a 
  6.     //     character, such as 'a', or '?', not an i
  7.     //     nteger. If you want to use integers, fir
  8.     //     st convert the integer using the chr() f
  9.     //     unction.Ported from ctype.h. by John
  10.     // By: PHP Code Exchange
  11.     //**************************************
  12.     //     
  13.     
  14.     <?php
  15.     /* Functions: Converted from <ctype.h>.
  16.     * Author: John Millaway
  17.     * 
  18.     * Note: These functions expect a character,
  19.     * such as 'a', or '?', not an integer.
  20.     * If you want to use integers, first convert
  21.     * the integer using the chr() function.
  22.     *
  23.     * Examples:
  24.     * 
  25.     * isalpha('a'); // returns 1
  26.     * isalpha(chr(97)); // same thing
  27.     *
  28.     * isdigit(1); // NO!
  29.     * isdigit('1'); // yes.
  30.     */
  31.     function isalnum ($c){ global $ctype__; return ((($ctype__[( ord($c) )]&(01 | 02 | 04 )) != 0)?1:0);}
  32.     function isalpha ($c){ global $ctype__; return ((($ctype__[( ord($c) )]&(01 | 02 )) != 0)?1:0);}
  33.     function isascii ($c){ global $ctype__; return (((( ord($c) )<=0177) != 0)?1:0);}
  34.     function iscntrl ($c){ global $ctype__; return ((($ctype__[( ord($c) )]& 040 ) != 0)?1:0);}
  35.     function isdigit ($c){ global $ctype__; return ((($ctype__[( ord($c) )]& 04 ) != 0)?1:0);}
  36.     function isgraph ($c){ global $ctype__; return ((($ctype__[( ord($c) )]&(020 | 01 | 02 | 04 )) != 0)?1:0);}
  37.     function islower ($c){ global $ctype__; return ((($ctype__[( ord($c) )]& 02 ) != 0)?1:0);}
  38.     function isprint ($c){ global $ctype__; return ((($ctype__[( ord($c) )]&(020 | 01 | 02 | 04 | 0200 )) != 0)?1:0);}
  39.     function ispunct ($c){ global $ctype__; return ((($ctype__[( ord($c) )]& 020 ) != 0)?1:0);}
  40.     function isspace ($c){ global $ctype__; return ((($ctype__[( ord($c) )]& 010 ) != 0)?1:0);}
  41.     function isupper ($c){ global $ctype__; return ((($ctype__[( ord($c) )]& 01 ) != 0)?1:0);}
  42.     function isxdigit ($c){ global $ctype__; return ((($ctype__[( ord($c) )]&(0100 | 04 )) != 0)?1:0);}
  43.     $ctype__ = array(32,32,32,32,32,32,32,32,32,40,40,40,40,40,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  44.     -120,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,4,4,4,4,4,4,4,4,4,4,16,16,16,16,16,16,
  45.     16,65,65,65,65,65,65,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,16,16,16,16,16,
  46.     16,66,66,66,66,66,66,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,16,16,16,16,32,
  47.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  48.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  49.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  50.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
  51.     ?>
  52.  
  53.